package io.renren.modules.lables.service;

import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import io.renren.datasource.annotation.DataSource;
import io.renren.modules.lables.entity.LabelTagBitmap;
import io.renren.modules.tag.service.TagRulesService;
import io.renren.modules.tag.service.TagsBasicInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.Map;

@Service
@DataSource("slave_3")
@Slf4j
public class LabelTagBitmapService {

    @Autowired
    private TagsBasicInfoService tagsBasicInfoService;
    @Autowired
    private TagRulesService tagRulesService;
    @Autowired
    private UserTagService userTagService;

    public boolean save(LabelTagBitmap entity) {
        Long useridl = Long.valueOf(entity.getUserid());
        Timestamp timestamp = Timestamp.valueOf(entity.getInsertTime());
        Map<String, Object> stringObjectMap = SqlRunner.db().selectOne("INSERT INTO `labels`.`label_tag_bitmap`  VALUES\n" +
                "({0}, {1}, {2},{3}, {4},to_bitmap({5}))", entity.getTagName(), entity.getTagValue(), useridl * 3L / 10000000000l, entity.getSubject(), timestamp.toString(), useridl);
        return true;
    }
}
